package com.Test.HomeWork;

import org.apache.commons.io.FileUtils;


import java.io.*;

public class demo1 {

    public static void main(String[] args) throws Exception {
        File file = new File("E:\\农大2112班\\视频\\20220517_183253(反射-2).mp4");


        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));


        File target = new File("f:\\"+file.getName());

        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(target));

        long bTime  = System.currentTimeMillis();

        byte[] buf = new byte[2048];
        int len = -1;
        while (  (len = bufferedInputStream.read(buf))!=-1){
                bufferedOutputStream.write(buf,0,len);
        }

        long eTime  = System.currentTimeMillis(); //46473   5秒

        System.out.println("读取时间为:"+(eTime-bTime));

        StreamUtils.close(bufferedInputStream,bufferedOutputStream);


    }
    public static void mmm() throws IOException {


            //copyDirectoryToDirectory():文件夹复制
            FileUtils.copyDirectoryToDirectory(new File("F:\\TestPath"),new File("D:\\"));

            //copyFile():文件复制
            FileUtils.copyFile(new File("F:\\TestPath\\FilePrintWriter.txt"),new File("D:\\b.txt"));

    }
}
